package com.atguigu.jxc.controller;


import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA
 *
 * @Author 花鸟の虫鱼
 * @CreateDate 21/9/4 14:50
 * @Version 1.0
 * @Description TODO
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    /**
     * @param q 进货入库，供应商下拉查询
     * @return
     */
    @RequestMapping("/getComboboxList")
    public List<Supplier> comboboxList(String q) {
        return supplierService.comboboxList(q);
    }


    /**
     * @param page 当前页数
     * @param rows 每页显示的记录数
     * @param supplierName
     * @return
     */
    @RequestMapping("/list")
    public Map<String, Object> list(Integer page, Integer rows, String supplierName) {
        return supplierService.list(page,rows,supplierName);
    }

   /**
     * 添加或修改角色信息
     * @param supplier 供应商角色信息
     * @return
     */
    @RequestMapping("/save")
    public ServiceVO save(Supplier supplier, @RequestParam(required = false) Integer supplierId) {
        supplier.setSupplierId(supplierId);
        return supplierService.save(supplier);
    }

    /**
     * 删除角色,支持批量删除
     * @param ids 供应商id
     * @return
     */
    @RequestMapping("/delete")
    public ServiceVO delete(String  ids) {
        return supplierService.delete(ids);
    }

}
